<!--
 * @Author: delin66
 * @Date: 2024-12-01 18:04:42
 * @LastEditors: delin66
 * @LastEditTime: 2025-06-04 18:07:54
 * @Descripttion: 
-->
<template>
  <div class="policy">
    <el-table border :data="policyList" style="width: 100%">
      <el-table-column align="center" label="高新技术企业">
        <template #default="{ row }">
          <div @click="toNoticeDetail(row.id)" class="c-p title">
            {{ row.title }}
          </div>
        </template>
      </el-table-column>
      <el-table-column align="center" width="150px" label="发布时间">
        <template #default="{ row }">
          <div>{{ row.createTime?.split(' ')[0] ?? '-' }}</div>
        </template>
      </el-table-column>
      <el-empty v-if="total === 0" description="没有高新技术企业" />
    </el-table>
    <el-pagination
      background
      class="m-t-10 m-b-10"
      style="justify-content: flex-end"
      layout="prev, pager, next"
      small
      :total="total"
      :page-size="requestData.size"
      v-model:current-page="requestData.current"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup lang="ts">
import { getAnnouncementList } from '@/api/park';
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';

onMounted(() => {
  loadData();
});
const requestData = ref({
  type: '9',
  current: 1,
  size: 10,
  status:1
});
const policyList = ref<any[]>([]);
const total = ref(0);
function loadData() {
  getAnnouncementList(requestData.value).then((res: any) => {
    if (res.code === 200) {
      policyList.value = res.data?.records;
      total.value = res.data?.total;
    }
  });
}

// 查看动态详情
const router = useRouter();
function toNoticeDetail(id: string | number) {
  const { href } = router.resolve({
    name: 'noticeDetail',
    query: {
      id,
    },
  });
  window.open(href, '_blank');
}

// 分页
function handleCurrentChange(val: number) {
  requestData.value.current = val;
  loadData();
}
</script>

<style lang="scss" scoped>
.policy {
  width: 100%;
  padding: 40px;
}
</style>
